var p = Object.defineProperty;
var u = (o, e, r) =>
  e in o
    ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r })
    : (o[e] = r);
var n = (o, e, r) => (u(o, typeof e != 'symbol' ? e + '' : e, r), r);
import { createNode as s } from '../doc/createNode.js';
import { stringifyPair as f } from '../stringify/stringifyPair.js';
import { addPairToJSMap as d } from './addPairToJSMap.js';
import { NODE_TYPE as m, PAIR as v, isNode as a } from './identity.js';
function O(o, e, r) {
  const i = s(o, void 0, r),
    l = s(e, void 0, r);
  return new t(i, l);
}
class t {
  constructor(e, r = null) {
    /** Always Node or null when parsed, but can be set to anything. */
    n(this, 'key');
    /** Always Node or null when parsed, but can be set to anything. */
    n(this, 'value');
    Object.defineProperty(this, m, { value: v }),
      (this.key = e),
      (this.value = r);
  }
  clone(e) {
    let { key: r, value: i } = this;
    return a(r) && (r = r.clone(e)), a(i) && (i = i.clone(e)), new t(r, i);
  }
  toJSON(e, r) {
    const i = r != null && r.mapAsMap ? /* @__PURE__ */ new Map() : {};
    return d(r, i, this);
  }
  toString(e, r, i) {
    return e != null && e.doc ? f(this, e, r, i) : JSON.stringify(this);
  }
}
export { t as Pair, O as createPair };
